<template>
  <div class="centerRight1">
    <div class="bg-color-black">
      <div class="d-flex pt-2 pl-2">
        <span>
          <i class="iconfont icon-align-left" />
        </span>
        <span class="fs-xxl text mx-2">设备分布</span>
        <dv-decoration-1 style="width:100px;height:20px;" :color="datavColors"/>
      </div>
      <div class="d-flex ai-center flex-column body-box">
        <dv-capsule-chart class="dv-cap-chart" :config="config" />
      </div>
    </div>
  </div>
</template>

<script>
import { defineComponent, reactive,computed, onMounted } from 'vue'
import { useStore } from 'vuex'
import { buildingDevice } from '@/public/request/http'
export default defineComponent({
  components: {
  },
  setup() {
    const datavColors = computed(() => useStore().state.datavColors)
    const config = reactive({
      data: []
    })

    // methods
    const setData = async () => {
      const res = await buildingDevice()
      config.data = []
      res.forEach((element,index) => {
        if(index < 15){
          config.data.push({name:element.name?element.name:'其他',value:element.totalCount})
        }
      });
    }

    onMounted(()=>{
      setData()
    })

    return { config,datavColors }
  }
})
</script>

<style lang="scss" scoped>
$box-height: 400px;
$box-width: 340px;
.centerRight1 {
  padding: 5px;
  height: $box-height;
  width: $box-width;
  border-radius: 5px;
  .bg-color-black {
    padding: 5px;
    height: $box-height;
    width: $box-width;
    border-radius: 10px;
  }
  .text {
    color: #c3cbde;
  }
  .body-box {
    border-radius: 10px;
    overflow: hidden;
    .dv-cap-chart {
      width: 100%;
      height: 360px;
    }
  }
}
</style>
